<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Changes in database support</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="migration51.datetime.html">Date/time support</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="migration51.errorcheck.html">Checking for E_STRICT</a></div>
 <div class="up"><a href="migration51.html">Migrating from PHP 5.0.x to PHP 5.1.x</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="migration51.databases" class="section">
  <h2 class="title">Changes in database support</h2>
  <ul class="itemizedlist">
   <li class="listitem">
    <p class="para">
     <a href="migration51.databases.html#migration51.databases-pdo" class="link">PDO overview</a>
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     <a href="migration51.databases.html#migration51.databases-mysql" class="link">Changes in MySQL support</a>
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     <a href="migration51.databases.html#migration51.databases-sqlite" class="link">Changes in SQLite support</a>
    </p>
   </li>
  </ul>

  <div class="section" id="migration51.databases-pdo">
   <h2 class="title">PDO overview</h2>
   <p class="para">
    <a href="intro.pdo.html" class="link">PHP Data Objects (PDO)</a> were introduced as a
    PECL extension under PHP 5.0, and became part of the core PHP distribution
    in PHP 5.1.x. The PDO extension provides a consistent interface for database
    access, and is used alongside database-specific PDO drivers. Each driver
    may also have database-specific functions of its own, but basic data
    access functionality such as issuing queries and fetching data is covered
    by PDO functions, using the driver named in
    <span class="function"><a href="pdo.construct.html" class="function">PDO::__construct()</a></span>.
   </p>
   <p class="para">
    Note that the PDO extension, and its drivers, are intended to be built as
    shared extensions. This will enable straightforward driver upgrades from
    PECL, without forcing you to rebuild all of PHP.
   </p>
   <p class="para">
    At the point of the PHP 5.1.x release, PDO is more than ready for widespread
    testing and could be adopted in most situations. However, it is important
    to understand that PDO and its drivers are comparatively young and may be
    missing certain database-specific features; evaluate PDO carefully before
    you use it in new projects.
   </p>
   <p class="para">
    Legacy code will generally rely on the pre-existing database extensions,
    which are still maintained.
   </p>
  </div>

  <div class="section" id="migration51.databases-mysql">
   <h2 class="title">Changes in MySQL support</h2>
   <p class="para">
    In PHP 4, MySQL 3 support was built-in. With the release of PHP 5.0 there
    were two MySQL extensions, named &#039;mysql&#039; and &#039;mysqli&#039;, which were designed
    to support MySQL &lt; 4.1 and MySQL 4.1 and up, respectively. With the
    introduction of PDO, which provides a very fast interface to all the
    database APIs supported by PHP, the PDO_MYSQL driver can support any of
    the current versions (MySQL 3, 4 or 5) in PHP code written for PDO,
    depending on the MySQL library version used during compilation. The older
    MySQL extensions remain in place for reasons of back compatibility, but
    are not enabled by default.
   </p>
  </div>

  <div class="section" id="migration51.databases-sqlite">
   <h2 class="title">Changes in SQLite support</h2>
   <p class="para">
    In PHP 5.0.x, SQLite 2 support was provided by the built-in sqlite
    extension, which was also available as a PECL extension in PHP 4.3 and PHP
    4.4. With the introduction of PDO, the sqlite extension doubles up to act
    as a &#039;sqlite2&#039; driver for PDO; it is due to this that the sqlite extension
    in PHP 5.1.x has a dependency upon the PDO extension.
   </p>
   <p class="para">
    PHP 5.1.x ships with a number of alternative interfaces to sqlite:
   </p>
   <p class="para">
    The sqlite extension provides the &quot;classic&quot; sqlite procedural/OO API that
    you may have used in prior versions of PHP. It also provides the PDO
    &#039;sqlite2&#039; driver, which allows you to access legacy SQLite 2 databases
    using the PDO API.
   </p>
   <p class="para">
    PDO_SQLITE provides the &#039;sqlite&#039; version 3 driver. SQLite version 3 is
    vastly superior to SQLite version 2, but the file formats of the two
    versions are not compatible.
   </p>
   <p class="para">
    If your SQLite-based project is already written and working against
    earlier PHP versions, then you can continue to use ext/sqlite without
    problems, but will need to explicitly enable both PDO and sqlite. New
    projects should use PDO and the &#039;sqlite&#039; (version 3) driver, as this is
    faster than SQLite 2, has improved locking concurrency, and supports both
    prepared statements and binary columns natively.
   </p>
   <p class="para">
    You must enable PDO to use the SQLite extension. If you want to build the
    PDO extension as a shared extension, then the SQLite extension must also
    be built shared. The same holds true for any extension that provides a PDO
    driver 
   </p>
  </div>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="migration51.datetime.html">Date/time support</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="migration51.errorcheck.html">Checking for E_STRICT</a></div>
 <div class="up"><a href="migration51.html">Migrating from PHP 5.0.x to PHP 5.1.x</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
